package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"week2/api/internal/config"
	"week2/api/internal/middleware"
	"week2/user_srv/userclient"
)

type ServiceContext struct {
	Config  config.Config
	UserSrv userclient.User
	Token   rest.Middleware //Token 自己定的 rest 应该是包名 Middleware 是目录
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:  c,
		UserSrv: userclient.NewUser(zrpc.MustNewClient(c.UserSrv)),
		//用自己定义的包名 调用new函数 . 上 handle方法
		Token: middleware.NewTokenMiddleware().Handle,
	}
}
